package JAVAcollectionsanddatastructures.Queue;

import java.util.Deque;
import java.util.LinkedList;
import java.util.Queue;

public class MyQueue {
    public static void main1(String[] args) {
        Queue<Integer> queue = new LinkedList<>();
        queue.offer(2);//入队
        queue.offer(3);
//        System.out.println(queue.peek());//返回队首元素
        System.out.println(queue.poll());//出队
        System.out.println(queue.peek());//返回队首元素
    }

    //双端队列，头尾都可以进出
    public static void main(String[] args) {
        Deque<Integer> deque = new LinkedList<>();
        //头部元素
//        deque.offerFirst(1);
//        deque.offerFirst(2);
//        deque.offerFirst(3);
//        System.out.println(deque.peekFirst());
//        System.out.println(deque.peekFirst());

        deque.offerLast(1);
        deque.offerLast(2);
        deque.offerLast(3);
        System.out.println(deque.peekLast());
        System.out.println(deque.pollLast());
    }
}
